home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / BCCollec / Tools / Search / BCSearcV.h < prev   
Encoding:
Text File  |  1994-04-21  |  2.5 KB  |  94 lines  |  [TEXT/MPS ]

  1. //  The C++ Booch Components (Version 2.1)
  2. //  (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
  3. //
  4. //  BCSearcV.h
  5. //
  6. //  This file contains the declaration of the vector searching tools.
  7.  
  8. #ifndef BCSEARCV_H
  9. #define BCSEARCV_H 1
  10.  
  11. #include "BCType.h"
  12.  
  13. // Vector searching abstract base class
  14.  
  15. template<class Item, class Sequence>
  16. class BC_TSearch {
  17. public:
  18.  
  19.   BC_TSearch();
  20.   BC_TSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
  21.   virtual ~BC_TSearch();
  22.   
  23.   virtual void
  24.     SetIsEqualFunction(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
  25.   virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
  26.                                     BC_Index start = 0) = 0;
  27.  
  28. protected:
  29.  
  30.   BC_Boolean (*fIsEqual)(const Item& x, const Item& y);
  31.   
  32. };
  33.  
  34. // Sequential searching class
  35.   
  36. template<class Item, class Sequence>
  37. class BC_TSequentialSearch : public BC_TSearch<Item, Sequence> {
  38. public:
  39.  
  40.   BC_TSequentialSearch();
  41.   BC_TSequentialSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
  42.   virtual ~BC_TSequentialSearch();
  43.   
  44.   virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
  45.                                     BC_Index start = 0);
  46.  
  47. };
  48.  
  49. // Ordered searching class
  50.   
  51. template<class Item, class Sequence>
  52. class BC_TOrderedSearch : public BC_TSearch<Item, Sequence> {
  53. public:
  54.  
  55.   BC_TOrderedSearch();
  56.   BC_TOrderedSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y),
  57.                     BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
  58.   virtual ~BC_TOrderedSearch();
  59.   
  60.   virtual void
  61.     SetIsLessThanFunction(BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
  62.   virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
  63.                                     BC_Index start = 0);
  64.  
  65. protected:
  66.  
  67.   BC_Boolean (*fIsLessThan)(const Item& x, const Item& y);
  68.   
  69. };
  70.  
  71. // Binary searching class
  72.  
  73. template<class Item, class Sequence>
  74. class BC_TBinarySearch : public BC_TSearch<Item, Sequence> {
  75. public:
  76.  
  77.   BC_TBinarySearch();
  78.   BC_TBinarySearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y),
  79.                    BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
  80.   virtual ~BC_TBinarySearch();
  81.   
  82.   virtual void
  83.     SetIsLessThanFunction(BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
  84.   virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
  85.                                     BC_Index start = 0);
  86.  
  87. protected:
  88.  
  89.   BC_Boolean (*fIsLessThan)(const Item& x, const Item& y);
  90.   
  91. };
  92.  
  93. #endif
  94.